$(function () {
    myAjax("#productCategoryLevel1", "0")

    function myAjax(categoryLevel, parentId) {
        $.getJSON("/getCategoryByParentId", {"parentId": parentId}, function (msg) {
            $(categoryLevel).empty().append('<option value="-1" selected="selected">请选择...</option>>')
            $("#productCategoryLevel3").empty().append('<option value="-1" selected="selected">请选择...</option>>')
            $(msg).each(function () {
                $(categoryLevel).append('<option value=' + this.id + '>' + this.name + '</option>>')
            });
        })
    }

    $("#productCategoryLevel1").change(function () {
        myAjax("#productCategoryLevel2", this.value);
    });
    $("#productCategoryLevel2").change(function () {
        myAjax("#productCategoryLevel3", this.value);
    });

    
})